package com.edfu.core.testmgt.persistence.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.edfu.core.commons.persistence.Discountable;
import com.edfu.core.commons.persistence.Sellable;

@Entity
@Table(name = "test_bundle", uniqueConstraints = @UniqueConstraint(columnNames = {"code"}))
public class TestBundleEntity implements ITestMgtEntity, Sellable, Discountable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	
	@Column(name = "code", length = 30, nullable = false)
	private String code;
	
	@Column(name = "name", nullable = false)
	private String name;
	
	@Column(name = "description", nullable = true)
	private String description;
	
	@Column(name = "publisher", nullable = true)
	private String publisher;
	
	@OneToMany(mappedBy = "testBundle", fetch = FetchType.EAGER, cascade = CascadeType.ALL )
	private Set<TestEntity> tests = new HashSet<TestEntity>();
	
	private boolean active = true;
	
	@Column(name = "price", nullable = true)
    private double price;
    
    @Column(name = "units", nullable = true)
    private String units;
    
    @Column(name = "discType", nullable = true)
    private String discType;
    
    @Column(name = "discValue", nullable = true)
	private double discValue;
    
    @Column(name = "discStart", nullable = true)
	private long discStart;
    
    @Column(name = "discEnd", nullable = true)
	private long discEnd;

	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}	

	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getPublisher() {
		return publisher;
	}
	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public Set<TestEntity> getTests() {
		return tests;
	}
	public void setTests(Set<TestEntity> tests) {
		this.tests = tests;
	}	
	
	public boolean isActive() {
		return active;
	}
	public void setActive(boolean active) {
		this.active = active;
	}
	
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	
	public String getUnits() {
		return units;
	}
	public void setUnits(String units) {
		this.units = units;
	}
	
	public String getDiscType() {
		return discType;
	}
	public void setDiscType(String discType) {
		this.discType = discType;
	}
	
	public double getDiscValue() {
		return discValue;
	}	
	public void setDiscValue(double discValue) {
		this.discValue = discValue;
	}
	
	public long getDiscStart() {
		return discStart;
	}	
	public void setDiscStart(long discStart) {
		this.discStart = discStart;
	}
	
	public long getDiscEnd() {
		return discEnd;
	}	
	public void setDiscEnd(long discEnd) {
		this.discEnd = discEnd;
	}
	@Override
	public String toString() {
		return "TestBundleEntity [code=" + code + ", name=" + name + "]";
	}

}
